# !/usr/bin/env python
# -*- coding:utf-8 -*-
# @FileName : zsj.py
# @Time     : 2024/4/21 17:12
# @Author   : Robot-Zsj
"""
description:

i:
mkdir abc
cd abc
pwd

o:
/abc/

"""


class TreeNode:
    def __init__(self, curDicName, father):
        self.curDicName = curDicName
        self.father = father
        self.children = {}


class Tree:
    def __init__(self):
        self.root = TreeNode("/", None)
        self.cur = self.root

    def mkdir(self, dicName):
        self.cur.children.setdefault(dicName, TreeNode(dicName + "/", self.cur))

    def cd(self, dicName):
        if dicName == "..":
            if self.cur.father is not None:
                self.cur = self.cur.father
        else:
            if self.cur.children.get(dicName) is not None:
                self.cur = self.cur.children[dicName]

    def pwd(self):
        lst = []

        cur = self.cur
        while cur is not None:
            lst.append(cur.curDicName)
            cur = cur.father

        lst.reverse()

        return "".join(lst)


tree = Tree()

lastCommandOutput = "/"

while True:
    try:
        line = input()
        tmp = line.split()
        cmd_key = tmp[0]

        if cmd_key == 'pwd':
            if len(tmp) != 1:
                continue
            lastCommandOutput = tree.pwd()
        elif cmd_key == 'mkdir' or cmd_key == 'cd':
            if len(tmp) != 2:
                continue

            cmd_val = tmp[1]

            if not (cmd_val.isalpha() and cmd_val.islower()) and not (cmd_val == 'cd' and cmd_val == '..'):
                continue

            if cmd_key == 'mkdir':
                tree.mkdir(cmd_val)
                lastCommandOutput = '/'
            else:
                tree.cd(cmd_val)
                lastCommandOutput = "/"
    except:
        break

print(lastCommandOutput)
